#include <iostream>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;

/** 
*   输入字符串规则：采用空格隔开连续的数字,数字都应该为正整数
*   测试案例：+82/*3-20 8 2
*   测试的正确结果：100
*   代码来源：https://www.bilibili.com/video/BV1Xk4y1T7va/?spm_id_from=333.337.search-card.all.click
*   代码经本人修改得到
**/

int main()
{
    stack<int> s;
    string str;
    getline(cin, str);
    for (int i = str.length() - 1; i >= 0; i--) {
        int sum = 0, k = 0;
        while (str[i] >= '0' && str[i] <= '9') {
            sum += (str[i] - '0') * pow(10, k++);
            if (i > 0) {
                i--;
            }
            else {
                cout << "缺乏操作符" << endl;
                exit(-1);
            }
            
        }
        if (sum != 0) {
            s.push(sum);
        }
        if (str[i]!=' ') {
            if (s.size() >= 2) {
                int num1 = s.top();
                s.pop();
                int num2 = s.top();
                s.pop();
                switch (str[i]) {
                case '+':
                    s.push(num1 + num2);
                    break;
                case '-':
                    s.push(num1 - num2);
                    break;
                case '*':
                    s.push(num1 * num2);
                    break;
                case '/':
                        s.push(num1 / num2);
                        break;
                default:
                    cout << "字符串错误,存在其他符号，请检查输入的字符串" << endl;
                    exit(-1);
                }
            }
            else {
                cout << "缺乏操作数" << endl;
                exit(-1);
            }
           
           
        }
        
    }
    if (s.size() == 1) {
        cout << s.top() << endl;
    }
    else {
        cout << "最终结果中包含多个操作数，请检查输入的字符串" << endl;
    }
}